package com.banfan.almond.web.controller;


import com.banfan.almond.utils.ResultUtil;
import com.banfan.almond.web.annotation.AuthorityVerify.AuthorityVerity;
import com.banfan.almond.web.security.SecurityUser;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/admin")
public class AdminApi implements ImportBeanDefinitionRegistrar {


    @AuthorityVerity
    @GetMapping()
    public String getAdmin() {
        return ResultUtil.successWithData("admin");
    }


    @GetMapping("/username")
    public String getUserName(Authentication authentication) {
        SecurityUser securityUser = (SecurityUser) authentication.getPrincipal();
        return ResultUtil.successWithData(securityUser.getUsername());
    }

}

